package com.leetcode;

/**
 * @author fy
 * @date 2022/3/29 17:36
 */
public class Solution62 {

    /**
     * 62. 不同路径
     *
     * @param m
     * @param n
     * @return
     */
    public int uniquePaths(int m, int n) {
        int[][] count = new int[m][n];
        for (int i = 0; i < n; i++) {
            count[0][i] = 1;
        }
        for (int j = 1; j < m; j++) {
            count[j][0] = 1;
        }
        for (int i = 1; i < m; i++) {
            for (int j = 1; j < n; j++) {
                count[i][j] = count[i - 1][j] + count[i][j - 1];
            }
        }
        return count[m - 1][n - 1];
    }

    public static void main(String[] args) {
        new Solution62().uniquePaths(3, 7);
    }

}
